package com.qidianit.mes.pro.controller;

import com.qidianit.mes.common.Result;
import com.qidianit.mes.pojo.pro.ProductionOrderBom;
import com.qidianit.mes.pro.service.ProductionOrderBomService;
import com.qidianit.mes.pro.service.ProductionOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Package Path: com.qidianit.mes.pro.controller
 * Author: Alhz
 * Description:
 * Date: 2025/9/22 20:20
 */
@RestController
@RequestMapping("/productionorderbom")
public class ProductionOrderBomController {
    @Autowired
    private ProductionOrderBomService productionOrderBomService;

    @GetMapping("/{id}")
    public Result selectAllProductionOrderBom(@PathVariable("id") Long productionOrderId,
                                              @RequestParam(defaultValue = "1") int page,
                                              @RequestParam(defaultValue = "10") int pageSize){
        System.out.println(productionOrderId);
        return productionOrderBomService.selectByProductionOrderId(productionOrderId,page,pageSize);
    }

    @PostMapping("/add")
    public Result addProductionOrderBom(@RequestBody ProductionOrderBom productionOrderBom){
        System.out.println(productionOrderBom);
        return  productionOrderBomService.addProductionOrderBom(productionOrderBom);
    }


    @DeleteMapping("/batchDelete")
    public Result deleteProductionOrderBom(Long[] ids){
        return productionOrderBomService.batchDeleteProductionOrderBom(ids);
    }

    @GetMapping("/detail/{id}")
    public Result detail(@PathVariable("id") Long id){
        return productionOrderBomService.selectByPrimaryKey(id);
    }

    @PutMapping("/update")
    public Result updateProductionOrderBom(@RequestBody ProductionOrderBom productionOrderBom){
        return productionOrderBomService.updateProductionOrderBom(productionOrderBom);
    }

}
